package com.aidemoconfidence.conf.Controller;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository("resultRepository")
public interface ResultRepository {
    @Select("select nickname from userinfo order by time")
    List<String> GetAllUser();

    @Select("select syscode,nickname from AIDEMO_USERROOT order by syscode")
    List<Map<String, String>> GetRootInfo();

    @Select("select distinct syscode from AIDEMO_USERROOT order by syscode")
    List<String> GetSyscode();

    @Select("select openid from userinfo where nickname = #{nickname}")
    String GetOpenid(String nickname);

    @Select("select max(aidemo_id) from AIDEMO_USERROOT")
    int GetMaxID();

    @Insert("insert into AIDEMO_USERROOT(syscode,nickname,openid,aidemo_id) values(#{syscode},#{nickname},#{openid},#{id})")
    int AddRoot(String syscode,String nickname,String openid,int id);

    @Delete("delete from AIDEMO_USERROOT where syscode = #{syscode} and nickname = #{nickname}")
    int DeleteRoot(String syscode,String nickname);
}
